package com.xscha.tableforge.jooq.tables;

import org.jooq.*;
import org.jooq.Record;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import java.time.LocalDateTime;

/**
 * 空间表
 * 用于存储空间的基本信息，包括空间名称、描述、图标等
 */
public class SpaceTable extends TableImpl<Record> {

    private static final long serialVersionUID = -1L;

    public static final SpaceTable SPACE = new SpaceTable();

	/** 空间ID */
	public final TableField<Record, String> ID = createField(DSL.name("id"), SQLDataType.VARCHAR.nullable(false), this);
	/** 空间名称 */
    public final TableField<Record, String> NAME = createField(DSL.name("name"), SQLDataType.VARCHAR.nullable(false), this);
    /** 空间描述 */
    public final TableField<Record, String> DESCRIPTION = createField(DSL.name("description"), SQLDataType.VARCHAR(255), this);
    /** 空间图标 */
    public final TableField<Record, String> LOGO = createField(DSL.name("logo"), SQLDataType.VARCHAR(255), this);
    /** 空间属性 */
    public final TableField<Record, String> SPACE_PROPS = createField(DSL.name("space_props"), SQLDataType.VARCHAR(2000), this);
    /** 删除时间 */
    public final TableField<Record, LocalDateTime> DELETED_TIME = createField(DSL.name("deleted_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 创建时间 */
    public final TableField<Record, LocalDateTime> CREATED_TIME = createField(DSL.name("created_time"), SQLDataType.LOCALDATETIME(3).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this);
    /** 创建人 */
    public final TableField<Record, String> CREATED_BY = createField(DSL.name("created_by"), SQLDataType.VARCHAR.nullable(false), this);
    /** 最后修改人 */
    public final TableField<Record, String> LAST_MODIFIED_BY = createField(DSL.name("last_modified_by"), SQLDataType.VARCHAR, this);
    /** 最后修改时间 */
    public final TableField<Record, LocalDateTime> LAST_MODIFIED_TIME = createField(DSL.name("last_modified_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 积分 */
    public final TableField<Record, Integer> CREDIT = createField(DSL.name("credit"), SQLDataType.INTEGER.nullable(false), this);

    private SpaceTable() {
        super(DSL.name("space"));
    }

    @Override
    public Schema getSchema() {
        return DSL.schema(DSL.name("public"));
    }

    @Override
    public UniqueKey<Record> getPrimaryKey() {
        return Keys.SPACE_PKEY;
    }

    @Override
    public SpaceTable as(String alias) {
        return new SpaceTable().as(alias);
    }

    @Override
    public SpaceTable as(Name alias) {
        return new SpaceTable().as(alias);
    }
} 